|
1
|
|
|
/*! |
|
2
|
|
|
* @name ElkArte Forum |
|
3
|
|
|
* @copyright ElkArte Forum contributors |
|
4
|
|
|
* @license BSD http://opensource.org/licenses/BSD-3-Clause |
|
5
|
|
|
* |
|
6
|
|
|
* This file contains code covered by: |
|
7
|
|
|
* copyright: 2011 Simple Machines (http://www.simplemachines.org) |
|
8
|
|
|
* license: BSD, See included LICENSE.TXT for terms and conditions. |
|
9
|
|
|
* |
|
10
|
|
|
* @version 1.1 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* This file contains javascript associated with the posting and previewing |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* A q&d wrapper function to call the correct preview function |
|
19
|
|
|
* @todo could make this a class to be cleaner |
|
20
|
|
|
*/ |
|
21
|
|
|
// These are variables the xml response is going to need |
|
22
|
|
|
var bPost; |
|
23
|
|
|
function previewControl() |
|
24
|
|
|
{ |
|
25
|
|
|
// Lets make a background preview request |
|
26
|
|
|
bPost = false; |
|
27
|
|
|
|
|
28
|
|
|
// call the needed preview function |
|
29
|
|
|
switch(preview_area) |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
case 'pm': |
|
32
|
|
|
previewPM(); |
|
33
|
|
|
break; |
|
34
|
|
|
case 'news': |
|
35
|
|
|
previewNews(); |
|
36
|
|
|
break; |
|
37
|
|
|
case 'post': |
|
38
|
|
|
bPost = true; |
|
39
|
|
|
previewPost(); |
|
40
|
|
|
break; |
|
41
|
|
|
} |
|
42
|
|
|
return false; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Used to preview a post |
|
47
|
|
|
*/ |
|
48
|
|
|
function previewPost() |
|
49
|
|
|
{ |
|
50
|
|
|
// @todo Currently not sending poll options and option checkboxes. |
|
51
|
|
|
var textFields = [ |
|
52
|
|
|
'subject', post_box_name, elk_session_var, 'icon', 'guestname', 'email', 'evtitle', 'question', 'topic' |
|
|
|
|
|
|
53
|
|
|
]; |
|
54
|
|
|
var numericFields = [ |
|
55
|
|
|
'board', 'topic', 'last_msg', |
|
56
|
|
|
'eventid', 'calendar', 'year', 'month', 'day', |
|
57
|
|
|
'poll_max_votes', 'poll_expire', 'poll_change_vote', 'poll_hide' |
|
58
|
|
|
]; |
|
59
|
|
|
var checkboxFields = [ |
|
60
|
|
|
'ns' |
|
61
|
|
|
]; |
|
62
|
|
|
|
|
63
|
|
|
// Get the values from the form |
|
64
|
|
|
var x = []; |
|
|
|
|
|
|
65
|
|
|
x = getFields(textFields, numericFields, checkboxFields, form_name); |
|
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
sendXMLDocument(elk_prepareScriptUrl(elk_scripturl) + 'action=post2' + (current_board ? ';board=' + current_board : '') + (make_poll ? ';poll' : '') + ';preview;xml', x.join('&'), onDocSent); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
// Show the preview section and load it with "pending results" text, onDocSent will finish things off |
|
70
|
|
|
document.getElementById('preview_section').style.display = 'block'; |
|
71
|
|
|
document.getElementById('preview_subject').innerHTML = txt_preview_title; |
|
|
|
|
|
|
72
|
|
|
document.getElementById('preview_body').innerHTML = txt_preview_fetch; |
|
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
return false; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Used to preview a PM |
|
79
|
|
|
*/ |
|
80
|
|
|
function previewPM() |
|
81
|
|
|
{ |
|
82
|
|
|
// define what we want to get from the form |
|
83
|
|
|
var textFields = [ |
|
84
|
|
|
'subject', post_box_name, 'to', 'bcc' |
|
|
|
|
|
|
85
|
|
|
]; |
|
86
|
|
|
var numericFields = [ |
|
87
|
|
|
'recipient_to[]', 'recipient_bcc[]' |
|
88
|
|
|
]; |
|
89
|
|
|
var checkboxFields = [ |
|
90
|
|
|
'outbox' |
|
91
|
|
|
]; |
|
92
|
|
|
|
|
93
|
|
|
// And go get them |
|
94
|
|
|
var x = []; |
|
|
|
|
|
|
95
|
|
|
x = getFields(textFields, numericFields, checkboxFields, form_name); |
|
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
// Send in document for previewing |
|
98
|
|
|
sendXMLDocument(elk_prepareScriptUrl(elk_scripturl) + 'action=pm;sa=send2;preview;xml', x.join('&'), onDocSent); |
|
|
|
|
|
|
99
|
|
|
|
|
100
|
|
|
// Show the preview section and load it with "pending results" text, onDocSent will finish things off |
|
101
|
|
|
document.getElementById('preview_section').style.display = 'block'; |
|
102
|
|
|
document.getElementById('preview_subject').innerHTML = txt_preview_title; |
|
|
|
|
|
|
103
|
|
|
document.getElementById('preview_body').innerHTML = txt_preview_fetch; |
|
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
return false; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Used to preview a News item |
|
110
|
|
|
*/ |
|
111
|
|
|
function previewNews() |
|
112
|
|
|
{ |
|
113
|
|
|
// define what we want to get from the form |
|
114
|
|
|
var textFields = [ |
|
115
|
|
|
'subject', post_box_name |
|
|
|
|
|
|
116
|
|
|
]; |
|
117
|
|
|
var numericFields = [ |
|
118
|
|
|
]; |
|
119
|
|
|
var checkboxFields = [ |
|
120
|
|
|
'send_html', 'send_pm' |
|
121
|
|
|
]; |
|
122
|
|
|
|
|
123
|
|
|
// And go get them |
|
124
|
|
|
var x = []; |
|
|
|
|
|
|
125
|
|
|
x = getFields(textFields, numericFields, checkboxFields, form_name); |
|
|
|
|
|
|
126
|
|
|
x[x.length] = 'item=newsletterpreview'; |
|
127
|
|
|
|
|
128
|
|
|
// Send in document for previewing |
|
129
|
|
|
sendXMLDocument(elk_prepareScriptUrl(elk_scripturl) + 'action=xmlpreview;xml', x.join('&'), onDocSent); |
|
|
|
|
|
|
130
|
|
|
|
|
131
|
|
|
// Show the preview section and load it with "pending results" text, onDocSent will finish things off |
|
132
|
|
|
document.getElementById('preview_section').style.display = 'block'; |
|
133
|
|
|
document.getElementById('preview_subject').innerHTML = txt_preview_title; |
|
|
|
|
|
|
134
|
|
|
document.getElementById('preview_body').innerHTML = txt_preview_fetch; |
|
|
|
|
|
|
135
|
|
|
|
|
136
|
|
|
return false; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Gets the form data for the selected fields so they can be posted via ajax |
|
141
|
|
|
* |
|
142
|
|
|
* @param {string[]} textFields |
|
143
|
|
|
* @param {string[]} numericFields |
|
144
|
|
|
* @param {string[]} checkboxFields |
|
145
|
|
|
* @param {string} form_name |
|
146
|
|
|
*/ |
|
147
|
|
|
function getFields(textFields, numericFields, checkboxFields, form_name) |
|
148
|
|
|
{ |
|
149
|
|
|
var fields = [], |
|
150
|
|
|
i = 0, |
|
151
|
|
|
n = 0; |
|
152
|
|
|
|
|
153
|
|
|
// Get all of the text fields |
|
154
|
|
|
for (i = 0, n = textFields.length; i < n; i++) |
|
155
|
|
|
{ |
|
156
|
|
|
if (textFields[i] in document.forms[form_name]) |
|
157
|
|
|
{ |
|
158
|
|
|
// Handle the editor. |
|
159
|
|
|
if (textFields[i] === post_box_name && $editor_data[post_box_name] !== undefined) |
|
|
|
|
|
|
160
|
|
|
{ |
|
161
|
|
|
fields[fields.length] = textFields[i] + '=' + $editor_data[post_box_name].getText().replace(/&#/g, '&#').php_urlencode(); |
|
162
|
|
|
fields[fields.length] = 'message_mode=' + $editor_data[post_box_name].inSourceMode(); |
|
163
|
|
|
} |
|
164
|
|
|
else |
|
165
|
|
|
fields[fields.length] = textFields[i] + '=' + document.forms[form_name][textFields[i]].value.replace(/&#/g, '&#').php_urlencode(); |
|
|
|
|
|
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
// All of the numeric fields |
|
170
|
|
|
for (i = 0, n = numericFields.length; i < n; i++) |
|
171
|
|
|
{ |
|
172
|
|
|
if (numericFields[i] in document.forms[form_name]) |
|
173
|
|
|
{ |
|
174
|
|
|
if ('value' in document.forms[form_name][numericFields[i]]) |
|
175
|
|
|
fields[fields.length] = numericFields[i] + '=' + parseInt(document.forms[form_name].elements[numericFields[i]].value); |
|
|
|
|
|
|
176
|
|
|
else |
|
177
|
|
|
{ |
|
178
|
|
|
for (var j = 0, num = document.forms[form_name][numericFields[i]].length; j < num; j++) |
|
179
|
|
|
fields[fields.length] = numericFields[i] + '=' + parseInt(document.forms[form_name].elements[numericFields[i]][j].value); |
|
|
|
|
|
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
// And the checkboxes |
|
185
|
|
|
for (i = 0, n = checkboxFields.length; i < n; i++) |
|
186
|
|
|
{ |
|
187
|
|
|
if (checkboxFields[i] in document.forms[form_name] && document.forms[form_name].elements[checkboxFields[i]].checked) |
|
188
|
|
|
fields[fields.length] = checkboxFields[i] + '=' + document.forms[form_name].elements[checkboxFields[i]].value; |
|
|
|
|
|
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
// And some security |
|
192
|
|
|
fields[fields.length] = elk_session_var + '=' + elk_session_id; |
|
|
|
|
|
|
193
|
|
|
|
|
194
|
|
|
return fields; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Callback function of the XMLhttp request |
|
199
|
|
|
* |
|
200
|
|
|
* @param {object} XMLDoc |
|
201
|
|
|
*/ |
|
202
|
|
|
function onDocSent(XMLDoc) |
|
203
|
|
|
{ |
|
204
|
|
|
var i = 0, |
|
205
|
|
|
n = 0, |
|
206
|
|
|
numErrors = 0, |
|
207
|
|
|
numCaptions = 0, |
|
208
|
|
|
$editor; |
|
209
|
|
|
|
|
210
|
|
|
if (!XMLDoc || !XMLDoc.getElementsByTagName('elk')[0]) |
|
211
|
|
|
{ |
|
212
|
|
|
document.forms[form_name].preview.onclick = function() {return true;}; |
|
|
|
|
|
|
213
|
|
|
document.forms[form_name].preview.click(); |
|
214
|
|
|
return true; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
// Read the preview section data from the xml response |
|
218
|
|
|
var preview = XMLDoc.getElementsByTagName('elk')[0].getElementsByTagName('preview')[0]; |
|
219
|
|
|
|
|
220
|
|
|
// Load in the subject |
|
221
|
|
|
document.getElementById('preview_subject').innerHTML = preview.getElementsByTagName('subject')[0].firstChild.nodeValue; |
|
222
|
|
|
|
|
223
|
|
|
// Load in the body |
|
224
|
|
|
var bodyText = ''; |
|
225
|
|
|
for (i = 0, n = preview.getElementsByTagName('body')[0].childNodes.length; i < n; i++) |
|
226
|
|
|
bodyText += preview.getElementsByTagName('body')[0].childNodes[i].nodeValue; |
|
|
|
|
|
|
227
|
|
|
|
|
228
|
|
|
document.getElementById('preview_body').innerHTML = bodyText; |
|
229
|
|
|
document.getElementById('preview_body').className = 'post'; |
|
230
|
|
|
|
|
231
|
|
|
// Show a list of errors (if any). |
|
232
|
|
|
var errors = XMLDoc.getElementsByTagName('elk')[0].getElementsByTagName('errors')[0], |
|
233
|
|
|
errorList = '', |
|
234
|
|
|
errorCode = '', |
|
235
|
|
|
error_area = 'post_error', |
|
236
|
|
|
error_list = error_area + '_list', |
|
237
|
|
|
error_post = false; |
|
238
|
|
|
|
|
239
|
|
|
// @todo: this should stay together with the rest of the error handling or |
|
240
|
|
|
// should use errorbox_handler (at the moment it cannot be used because is not enough generic) |
|
241
|
|
|
for (i = 0, numErrors = errors.getElementsByTagName('error').length; i < numErrors; i++) |
|
242
|
|
|
{ |
|
243
|
|
|
errorCode = errors.getElementsByTagName('error')[i].attributes.getNamedItem("code").value; |
|
244
|
|
|
if (errorCode === 'no_message' || errorCode === 'long_message') |
|
245
|
|
|
error_post = true; |
|
|
|
|
|
|
246
|
|
|
errorList += '<li id="' + error_area + '_' + errorCode + '" class="error">' + errors.getElementsByTagName('error')[i].firstChild.nodeValue + '</li>'; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
var oError_box = $(document.getElementById(error_area)); |
|
250
|
|
|
if ($.trim(oError_box.children(error_list).html()) === '') |
|
251
|
|
|
oError_box.append("<ul id='" + error_list + "'></ul>"); |
|
|
|
|
|
|
252
|
|
|
|
|
253
|
|
|
// Add the error it and show it |
|
254
|
|
|
if (numErrors === 0) |
|
255
|
|
|
oError_box.css("display", "none"); |
|
|
|
|
|
|
256
|
|
|
else |
|
257
|
|
|
{ |
|
258
|
|
|
document.getElementById(error_list).innerHTML = errorList; |
|
259
|
|
|
oError_box.css("display", ""); |
|
260
|
|
|
oError_box.attr('class', parseInt(errors.getAttribute('serious')) === 0 ? 'warningbox' : 'errorbox'); |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
// Show a warning if the topic has been locked. |
|
264
|
|
|
if (bPost) |
|
265
|
|
|
document.getElementById('lock_warning').style.display = parseInt(errors.getAttribute('topic_locked')) === 1 ? '' : 'none'; |
|
|
|
|
|
|
266
|
|
|
|
|
267
|
|
|
// Adjust the color of captions if the given data is erroneous. |
|
268
|
|
|
var captions = errors.getElementsByTagName('caption'); |
|
269
|
|
|
for (i = 0, numCaptions = errors.getElementsByTagName('caption').length; i < numCaptions; i++) |
|
270
|
|
|
{ |
|
271
|
|
|
if (document.getElementById('caption_' + captions[i].getAttribute('name'))) |
|
272
|
|
|
document.getElementById('caption_' + captions[i].getAttribute('name')).className = captions[i].getAttribute('class'); |
|
|
|
|
|
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
if (typeof $editor_container[post_box_name] !== 'undefined') |
|
|
|
|
|
|
276
|
|
|
$editor = $editor_container[post_box_name]; |
|
|
|
|
|
|
277
|
|
|
else |
|
278
|
|
|
$editor = $(document.forms[form_name][post_box_name]); |
|
279
|
|
|
|
|
280
|
|
|
if (error_post) |
|
281
|
|
|
$editor.find("textarea, iframe").addClass('border_error'); |
|
|
|
|
|
|
282
|
|
|
else |
|
283
|
|
|
$editor.find("textarea, iframe").removeClass('border_error'); |
|
284
|
|
|
|
|
285
|
|
|
// If this is a post preview, then we have some extra work to do |
|
286
|
|
|
if (bPost) |
|
287
|
|
|
{ |
|
288
|
|
|
// Set the new last message id. |
|
289
|
|
|
if ('last_msg' in document.forms[form_name]) |
|
290
|
|
|
document.forms[form_name].last_msg.value = XMLDoc.getElementsByTagName('elk')[0].getElementsByTagName('last_msg')[0].firstChild.nodeValue; |
|
|
|
|
|
|
291
|
|
|
|
|
292
|
|
|
var new_replies = [], |
|
293
|
|
|
ignored_replies = [], |
|
294
|
|
|
ignoring = null, |
|
|
|
|
|
|
295
|
|
|
newPosts = XMLDoc.getElementsByTagName('elk')[0].getElementsByTagName('new_posts')[0] ? XMLDoc.getElementsByTagName('elk')[0].getElementsByTagName('new_posts')[0].getElementsByTagName('post') : {length: 0}, |
|
296
|
|
|
numNewPosts = newPosts.length; |
|
297
|
|
|
|
|
298
|
|
|
if (numNewPosts !== 0) |
|
299
|
|
|
{ |
|
300
|
|
|
var newPostsHTML = '<span id="new_replies"><' + '/span>'; |
|
301
|
|
|
for (i = 0; i < numNewPosts; i++) |
|
302
|
|
|
{ |
|
303
|
|
|
new_replies[new_replies.length] = newPosts[i].getAttribute("id"); |
|
304
|
|
|
|
|
305
|
|
|
ignoring = false; |
|
306
|
|
|
if (newPosts[i].getElementsByTagName("is_ignored")[0].firstChild.nodeValue !== '0') |
|
307
|
|
|
ignored_replies[ignored_replies.length] = ignoring = newPosts[i].getAttribute("id"); |
|
|
|
|
|
|
308
|
|
|
|
|
309
|
|
|
newPostsHTML += '<div class="content' + (++reply_counter % 2 === 0 ? '2' : '') + '"><div class="postarea2" id="msg' + newPosts[i].getAttribute("id") + '"><div class="keyinfo">'; |
|
|
|
|
|
|
310
|
|
|
newPostsHTML += '<h5 class="floatleft"><span>' + txt_posted_by + '</span> ' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + ' - ' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue; |
|
|
|
|
|
|
311
|
|
|
newPostsHTML += ' <span class="new_posts" id="image_new_' + newPosts[i].getAttribute("id") + '">' + txt_new + '</span></h5>'; |
|
|
|
|
|
|
312
|
|
|
|
|
313
|
|
|
if (can_quote) |
|
|
|
|
|
|
314
|
|
|
newPostsHTML += '<ul class="quickbuttons" id="msg_' + newPosts[i].getAttribute('id') + '_quote"><li class="listlevel1"><a href="#postmodify" onmousedown="return insertQuoteFast(' + newPosts[i].getAttribute('id') + ');" class="linklevel1 quote_button">' + txt_bbc_quote + '</a></li></ul>'; |
|
|
|
|
|
|
315
|
|
|
|
|
316
|
|
|
newPostsHTML += '</div>'; |
|
317
|
|
|
|
|
318
|
|
|
if (ignoring) |
|
319
|
|
|
newPostsHTML += '<div id="msg_' + newPosts[i].getAttribute("id") + '_ignored_prompt">' + txt_ignoring_user + '<a href="#" id="msg_' + newPosts[i].getAttribute("id") + '_ignored_link" class="hide">' + show_ignore_user_post + '</a></div>'; |
|
|
|
|
|
|
320
|
|
|
|
|
321
|
|
|
newPostsHTML += '<div class="inner" id="msg_' + newPosts[i].getAttribute("id") + '_body">' + newPosts[i].getElementsByTagName("message")[0].firstChild.nodeValue + '</div></div></div>'; |
|
322
|
|
|
} |
|
323
|
|
|
setOuterHTML(document.getElementById('new_replies'), newPostsHTML); |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
// Remove the new image from old-new replies! |
|
327
|
|
|
for (i = 0; i < new_replies.length; i++) |
|
328
|
|
|
document.getElementById('image_new_' + new_replies[i]).style.display = 'none'; |
|
|
|
|
|
|
329
|
|
|
|
|
330
|
|
|
var numIgnoredReplies = ignored_replies.length; |
|
331
|
|
|
if (numIgnoredReplies !== 0) |
|
332
|
|
|
{ |
|
333
|
|
|
for (i = 0; i < numIgnoredReplies; i++) |
|
334
|
|
|
{ |
|
335
|
|
|
aIgnoreToggles[ignored_replies[i]] = new elk_Toggle({ |
|
|
|
|
|
|
336
|
|
|
bToggleEnabled: true, |
|
337
|
|
|
bCurrentlyCollapsed: true, |
|
338
|
|
|
aSwappableContainers: [ |
|
339
|
|
|
'msg_' + ignored_replies[i] + '_body', |
|
340
|
|
|
'msg_' + ignored_replies[i] + '_quote' |
|
341
|
|
|
], |
|
342
|
|
|
aSwapLinks: [ |
|
343
|
|
|
{ |
|
344
|
|
|
sId: 'msg_' + ignored_replies[i] + '_ignored_link', |
|
345
|
|
|
msgExpanded: '', |
|
346
|
|
|
msgCollapsed: show_ignore_user_post |
|
347
|
|
|
} |
|
348
|
|
|
] |
|
349
|
|
|
}); |
|
350
|
|
|
} |
|
351
|
|
|
} |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
$('html, body').animate({ scrollTop: $('#preview_section').offset().top }, 'slow'); |
|
355
|
|
|
|
|
356
|
|
|
// Preview video links if the feature is available |
|
357
|
|
|
if ($.isFunction($.fn.linkifyvideo)) |
|
358
|
|
|
$().linkifyvideo(oEmbedtext, 'preview_body'); |
|
|
|
|
|
|
359
|
|
|
|
|
360
|
|
|
// Spoilers, Sweetie |
|
361
|
|
|
$('.spoilerheader').on('click', function(){ |
|
362
|
|
|
$(this).next().children().slideToggle("fast"); |
|
363
|
|
|
}); |
|
364
|
|
|
|
|
365
|
|
|
// Fix and Prettify code blocks |
|
366
|
|
|
if (typeof elk_codefix === 'function') |
|
|
|
|
|
|
367
|
|
|
elk_codefix(); |
|
|
|
|
|
|
368
|
|
|
if (typeof prettyPrint === 'function') |
|
|
|
|
|
|
369
|
|
|
prettyPrint(); |
|
|
|
|
|
|
370
|
|
|
|
|
371
|
|
|
// Prevent lighbox or default action on the preview |
|
372
|
|
|
$('[data-lightboximage]').on('click.elk_lb', function(e) { |
|
373
|
|
|
e.preventDefault(); |
|
374
|
|
|
}); |
|
|
|
|
|
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* Add additional poll option fields |
|
379
|
|
|
*/ |
|
380
|
|
|
function addPollOption() |
|
381
|
|
|
{ |
|
382
|
|
|
var pollTabIndex; |
|
383
|
|
|
|
|
384
|
|
|
if (pollOptionNum === 0) |
|
|
|
|
|
|
385
|
|
|
{ |
|
386
|
|
|
for (var i = 0, n = document.forms[form_name].elements.length; i < n; i++) |
|
|
|
|
|
|
387
|
|
|
if (document.forms[form_name].elements[i].id.substr(0, 8) === 'options-') |
|
|
|
|
|
|
388
|
|
|
{ |
|
389
|
|
|
pollOptionNum++; |
|
|
|
|
|
|
390
|
|
|
pollTabIndex = document.forms[form_name].elements[i].tabIndex; |
|
391
|
|
|
} |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
pollOptionNum++; |
|
395
|
|
|
pollOptionId++; |
|
|
|
|
|
|
396
|
|
|
pollTabIndex++; |
|
|
|
|
|
|
397
|
|
|
setOuterHTML(document.getElementById('pollMoreOptions'), '<li><label for="options-' + pollOptionId + '">' + txt_option + ' ' + pollOptionNum + '</label>: <input type="text" name="options[' + pollOptionId + ']" id="options-' + pollOptionId + '" value="" size="80" maxlength="255" tabindex="' + pollTabIndex + '" class="input_text" /></li><li id="pollMoreOptions"></li>'); |
|
|
|
|
|
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
/** |
|
401
|
|
|
* Add additional attachment selection boxes |
|
402
|
|
|
*/ |
|
403
|
|
|
function addAttachment() |
|
404
|
|
|
{ |
|
405
|
|
|
/** global: allowed_attachments */ |
|
406
|
|
|
allowed_attachments -= 1; |
|
|
|
|
|
|
407
|
|
|
/** global: current_attachment */ |
|
408
|
|
|
current_attachment += 1; |
|
|
|
|
|
|
409
|
|
|
|
|
410
|
|
|
if (allowed_attachments <= 0) |
|
411
|
|
|
return alert(txt_more_attachments_error); |
|
|
|
|
|
|
412
|
|
|
|
|
413
|
|
|
setOuterHTML(document.getElementById("moreAttachments"), '<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment' + current_attachment + '" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment' + current_attachment + '\');">' + txt_clean_attach + '<\/a>)' + '<\/dd><dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(' + txt_more_attachments + ')</a></dd>'); |
|
|
|
|
|
|
414
|
|
|
|
|
415
|
|
|
return true; |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
/** |
|
419
|
|
|
* A function used to clear the attachments on post page. For security reasons |
|
420
|
|
|
* browsers don't let you set the value of a file input, even to an empty string |
|
421
|
|
|
* so this work around lets the user clear a choice. |
|
422
|
|
|
* |
|
423
|
|
|
* @param {type} idElement |
|
424
|
|
|
* @returns {undefined} |
|
425
|
|
|
*/ |
|
426
|
|
|
function cleanFileInput(idElement) |
|
427
|
|
|
{ |
|
428
|
|
|
var oElement = $('#' + idElement); |
|
429
|
|
|
|
|
430
|
|
|
// Wrap the element in its own form, then reset the wrapper form |
|
431
|
|
|
oElement.wrap('<form>').closest('form').get(0).reset(); |
|
432
|
|
|
oElement.unwrap(); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* Insert a quote to the editor via ajax |
|
437
|
|
|
* |
|
438
|
|
|
* @param {string} messageid |
|
439
|
|
|
*/ |
|
440
|
|
|
function insertQuoteFast(messageid) |
|
441
|
|
|
{ |
|
442
|
|
|
getXMLDocument(elk_prepareScriptUrl(elk_scripturl) + 'action=quotefast;quote=' + messageid + ';xml;pb=' + post_box_name + ';mode=0', onDocReceived); |
|
|
|
|
|
|
443
|
|
|
|
|
444
|
|
|
return true; |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* callback for the quotefast function |
|
449
|
|
|
* |
|
450
|
|
|
* @param {object} XMLDoc |
|
451
|
|
|
*/ |
|
452
|
|
|
function onDocReceived(XMLDoc) |
|
453
|
|
|
{ |
|
454
|
|
|
var text = ''; |
|
455
|
|
|
|
|
456
|
|
|
for (var i = 0, n = XMLDoc.getElementsByTagName('quote')[0].childNodes.length; i < n; i++) |
|
457
|
|
|
text += XMLDoc.getElementsByTagName('quote')[0].childNodes[i].nodeValue + "\n"; |
|
|
|
|
|
|
458
|
|
|
|
|
459
|
|
|
$editor_data[post_box_name].insert(text); |
|
|
|
|
|
|
460
|
|
|
|
|
461
|
|
|
ajax_indicator(false); |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
/** |
|
465
|
|
|
* Insert text in to the editor |
|
466
|
|
|
* |
|
467
|
|
|
* @param {string} text |
|
468
|
|
|
*/ |
|
469
|
|
|
function onReceiveOpener(text) |
|
470
|
|
|
{ |
|
471
|
|
|
$editor_data[post_box_name].insert(text); |
|
|
|
|
|
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
/** |
|
475
|
|
|
* The actual message icon selector, shows the chosen icon on the post screen |
|
476
|
|
|
*/ |
|
477
|
|
|
function showimage() |
|
478
|
|
|
{ |
|
479
|
|
|
document.images.icons.src = icon_urls[document.forms.postmodify.icon.options[document.forms.postmodify.icon.selectedIndex].value]; |
|
|
|
|
|
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
/** |
|
483
|
|
|
* When using Go Back due to fatal_error, allows the form to be re-submitted with change |
|
484
|
|
|
* Done as a pageshow event listener for FF only |
|
485
|
|
|
*/ |
|
486
|
|
|
function reActivate() |
|
487
|
|
|
{ |
|
488
|
|
|
document.forms.postmodify.message.readOnly = false; |
|
489
|
|
|
} |
|
490
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.